package com.dl.leetcode;

/**
 * @author DL
 * @create 2023-06-08 10:16
 */
public class LeetCode230701 {

    //删除有序数组中的重复项
    public int removeDuplicates(int[] nums) {
        // 0 1 2 2 3 -> 0 1 2 3 3
        if (nums.length <= 1) {
            return 1;
        }
        int j = 0;
        for (int i = 1; i < nums.length; i++) {
            if (nums[i] != nums[i - 1]) {
                nums[++j] = nums[i];
            }
        }
        return j + 1;
    }

}
